INCLUDE = -I. -I.. -I../ctests
TESTS 	= strtest zero first  second tenth description fdmemtest\
          accum highlevel cost johnmay2 native \
	  avail case1 case2 clockres eventname fmatrixlowpapi \
	  fmatrixpapi fmatrixpapi2 flops fmultiplex1 fmultiplex2
PAPILIB	= do_loops.o dummy.o ftests_util.o ../$(LIBRARY)
FTEST_DEPENDENCE=$(PAPILIB) fpapi_test.h ../fpapi.h ../ctests/test_utils.h

default: $(TESTS)

attach:

p4:

ear:

range:

mpi:

shared:

multiplex:

omp:

smp: 

pthreads:

shmem:

multiplex_and_pthreads: 

serial:  $(TESTS)

clockres: clockres.F $(FTEST_DEPENDENCE) 
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) clockres.F $(PAPILIB) $(LDFLAGS) -o clockres

avail: avail.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) avail.F  $(PAPILIB) $(LDFLAGS) -o avail

eventname: eventname.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) eventname.F $(PAPILIB) $(LDFLAGS) -o eventname

case1: case1.F $(FTEST_DEPENDENCE) 
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) case1.F $(PAPILIB) $(LDFLAGS) -o case1

case2: case2.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) case2.F $(PAPILIB) $(LDFLAGS) -o case2

fdmemtest: fdmemtest.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) fdmemtest.F $(PAPILIB) $(LDFLAGS) -o fdmemtest

fmatrixlowpapi: fmatrixlowpapi.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) fmatrixlowpapi.F $(PAPILIB) $(LDFLAGS) -o fmatrixlowpapi

fmatrixpapi: fmatrixpapi.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) fmatrixpapi.F $(PAPILIB) $(LDFLAGS) -o fmatrixpapi

fmatrixpapi2: fmatrixpapi2.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) fmatrixpapi2.F $(PAPILIB) $(LDFLAGS) -o fmatrixpapi2

strtest: strtest.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) strtest.F $(PAPILIB) $(LDFLAGS) -o strtest

flops: flops.F $(FTEST_DEPENDENCE)  
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) flops.F $(PAPILIB) $(LDFLAGS) -o flops

description: description.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) description.F $(PAPILIB) $(LDFLAGS) -o description

accum: accum.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) accum.F $(PAPILIB) -o accum $(LDFLAGS)

highlevel: highlevel.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) highlevel.F $(PAPILIB) -o highlevel $(LDFLAGS)

zero: zero.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) zero.F $(PAPILIB) -o zero $(LDFLAGS)

first: first.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) first.F $(PAPILIB) -o first $(LDFLAGS)

second: second.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) second.F $(PAPILIB) -o second $(LDFLAGS)

tenth: tenth.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) tenth.F $(PAPILIB) -o tenth $(LDFLAGS)

cost: cost.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) cost.F $(PAPILIB) -o cost $(LDFLAGS)

johnmay2: johnmay2.F $(FTEST_DEPENDENCE)
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) johnmay2.F $(PAPILIB) -o johnmay2 $(LDFLAGS)

native: native.F $(FTEST_DEPENDENCE) 
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) native.F $(PAPILIB) -o native $(LDFLAGS)

fmultiplex1: fmultiplex1.F $(FTEST_DEPENDENCE) 
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) fmultiplex1.F $(PAPILIB) -o fmultiplex1 $(LDFLAGS)


fmultiplex2: fmultiplex2.F $(FTEST_DEPENDENCE) 
	$(F77) $(FTOPTFLAGS) $(FFLAGS) $(INCLUDE) fmultiplex2.F $(PAPILIB) -o fmultiplex2 $(LDFLAGS)

ftests_util.o: ftests_util.F fpapi_test.h ../fpapi.h ../ctests/test_utils.h
	$(F77) $(FTOPTFLAGS) -c $(FFLAGS) $(INCLUDE) ftests_util.F

do_loops.o: ../ctests/do_loops.c ../ctests/papi_test.h ../ctests/test_utils.h
	$(CC) $(CFLAGS) $(INCLUDE) $(TOPTFLAGS) -c ../ctests/do_loops.c

dummy.o: ../ctests/dummy.c
	$(CC) $(CFLAGS) $(INCLUDE) $(TOPTFLAGS) -c ../ctests/dummy.c

clean:
	rm -f *.o *.stderr *.stdout core *~ $(TESTS)

install: $(TARGETS)
	@echo "Fortran tests (DATADIR) being installed in: \"$(DATADIR)\""; 
	-mkdir -p $(DATADIR)/ftests
	-chmod go+rx $(DATADIR)
	-chmod go+rx $(DATADIR)/ftests
	-find . -perm -100 -type f -exec cp {} $(DATADIR)/ftests \;
	-chmod go+rx $(DATADIR)/ftests/*
	-find . -name "*.F" -type f -exec cp {} $(DATADIR)/ftests \;
